package com.qiyu.tech.tcc.starter.service;

import com.qiyu.tech.tcc.starter.dao.StockFreezeDao;
import com.qiyu.tech.tcc.starter.model.StockFreeze;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;

/**
 * @author linhao
 * @date created in 4:26 下午 2020/11/4
 */
@Service
public class StockFreezeService {

    @Resource
    private StockFreezeDao stockFreezeDao;

    public int insertOne(StockFreeze stockFreeze) {
        try {
            int id = stockFreezeDao.insert(stockFreeze);
            return id;
        } catch (Exception e) {
            e.printStackTrace();
            return -1;
        }
    }


    /**
     * 修改锁定
     *
     * @param id
     * @param status @see StockFreezeEnum
     * @return
     */
    public boolean changeValidStatus(int id, int status) {
        try {
            stockFreezeDao.updateValidStatus(status, id);
            return true;
        } catch (Exception e) {
            e.printStackTrace();
            return false;
        }
    }
}
